package com.example.demo.entity.pojo.supplier;

import com.baomidou.mybatisplus.annotation.TableName;
import com.example.demo.common.entity.pojo.BaseEntityPoJo;
import com.example.demo.entity.request.supplier.SupplierRequest;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.util.Objects;

/**
 * 供应商实体.
 *
 * @author Mei Ruoxiao
 * @since 2020/9/16
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@ApiModel("供应商信息")
@TableName(value = "supplier")
public class SupplierPoJo extends BaseEntityPoJo {

    @ApiModelProperty(value = "企业名称", example = "鸿达安视")
    private String name;

    @ApiModelProperty(value = "联系人", example = "张国强")
    private String boss;

    @ApiModelProperty(value = "联系人电话", example = "18523659852")
    private String tel;

    @ApiModelProperty(value = "收货地址", example = "锦江区东门大街")
    private String address;

    @ApiModelProperty(value = "公账账户", example = "98523641252285411")
    private String account;

    @ApiModelProperty(value = "开户行", example = "中国银行")
    private String bank;

    @ApiModelProperty(value = "税号", example = "35852841258844")
    private String taxId;

    @ApiModelProperty(value = "税务地址", example = "苏坡街道")
    private String taxAddress;

    @ApiModelProperty(value = "税务电话", example = "18236955236")
    private String taxTel;

    public static SupplierPoJo of(final SupplierRequest request) {

        SupplierPoJo poJo = new SupplierPoJo();
        if (Objects.isNull(request)) {
            return poJo;
        }
        // 将 Response 对象转换成 PoJo 对象
        BeanUtils.copyProperties(request, poJo);
        return poJo;
    }

}
